Skip to content

Add NIDQ and LF stream support to SpikeGLX reader#5

Merged
stevevanhooser merged 2 commits intomainfrom
claude/add-nidq-stream-support-GE9xl
Apr 13, 2026
Merged

Add NIDQ and LF stream support to SpikeGLX reader#5
stevevanhooser merged 2 commits intomainfrom
claude/add-nidq-stream-support-GE9xl

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

Extended the SpikeGLX reader to support NIDQ (NI-DAQ) and LF (low-frequency) streams in addition to the existing AP (action-potential) stream support. This enables reading data from multiple stream types acquired with SpikeGLX software.

Key Changes

Reader (ndr_reader_neuropixelsGLX)

  • Multi-stream support: Updated class docstring and logic to handle AP, LF, and NIDQ streams instead of AP-only
  • File disambiguation: Enhanced filenamefromepochfiles() to intelligently select the correct .meta file when multiple streams are present by preferring .bin file matching, allowing AP and NIDQ files to coexist in the same epoch file list
  • Digital line expansion: Changed from exposing a single sync channel (di1) to exposing individual digital bit lines (di1..diM), where M depends on the stream type:
    • IMEC streams (AP/LF): 16 bits per sync column
    • NIDQ streams: 8 bits per active byte (determined by niXDBytes1/niXDBytes2)
  • Digital data reading: Completely rewrote readchannels_epochsamples() digital_in branch to extract individual bits from packed digital word columns instead of returning raw sync words

Header Parser (ndr/format/neuropixelsGLX/header.py)

  • Stream type detection: Added support for parsing both IMEC (snsApLfSy) and NIDQ (snsMnMaXaDw) metadata formats
  • NIDQ channel parsing: Added extraction of MN (multiplexed neural), MA (multiplexed analog), XA (non-multiplexed analog), and DW (digital word) channel counts
  • Digital line mapping: Implemented comprehensive digital line metadata:
    • n_digital_lines: Total number of individual bit lines exposed
    • digital_line_col: 0-based column offset for each line within the digital word columns
    • digital_line_bit: 0-based bit position within the column
    • digital_line_label: Human-readable labels (e.g., "XD0", "SY0.6")
  • NIDQ voltage range: Added support for niAiRangeMax/niAiRangeMin metadata fields
  • NIDQ max int: Added support for niMaxInt metadata field
  • NI-DAQ gains: Added optional parsing of niMNGain and niMAGain fields

Tests (tests/test_neuropixelsGLX.py)

  • Comprehensive test suite with 464 lines covering:
    • Header parsing for both NIDQ and AP streams
    • File discovery and disambiguation logic
    • Channel enumeration and naming
    • Sample rate retrieval
    • Time range queries
    • Analog channel reading
    • Digital bit extraction with multiple test cases validating bit patterns
    • Edge cases (out-of-range digital lines, missing files)
    • Epoch clock metadata

Notable Implementation Details

  • Digital bit extraction uses bitwise operations on uint16 views of the raw int16 data to preserve sign-bit handling
  • The digital line mapping supports multiple digital word columns, allowing for future expansion beyond the current 8-16 bit limits
  • Backward compatibility maintained: existing AP-only code paths continue to work unchanged

https://claude.ai/code/session_01HEWqAySjSJ6dFeNWJrdsrJ

claude added 2 commits April 13, 2026 11:21
The neuropixelsGLX reader previously only handled Imec AP-band streams
(.ap.meta/.ap.bin). This adds full support for NIDQ streams
(.nidq.meta/.nidq.bin), matching the NDR-matlab reference implementation.

Changes:
- header.py: Parse snsMnMaXaDw with full MN/MA/XA/DW breakdown. Compute
  per-bit digital line mapping from niXDBytes1/niXDBytes2. Add
  niAiRangeMax/Min, niMaxInt, and NI-DAQ gain fields. Also add digital
  line mapping for IMEC sync words (16 bits per sync column).
- neuropixelsGLX.py: Rewrite filenamefromepochfiles() to find .bin first
  and derive .meta (matching MATLAB), allowing mixed AP+NIDQ epoch lists.
  Update getchannelsepoch() to expose individual digital lines via
  n_digital_lines. Update readchannels_epochsamples() digital_in to
  extract single bits from packed digital words using bitwise operations.
- Add 39 new tests covering header parsing, channel enumeration, sample
  reading, and bit extraction for both NIDQ and AP streams.

https://claude.ai/code/session_01HEWqAySjSJ6dFeNWJrdsrJ
The test-symmetry workflow tried to check out NDR-matlab at the same
branch name as the PR, failing when no matching branch existed. Add a
resolve step that checks if the branch exists via git ls-remote and
falls back to main.

Also fix black formatting and remove unused import.

https://claude.ai/code/session_01HEWqAySjSJ6dFeNWJrdsrJ
@stevevanhooser stevevanhooser merged commit 896ed63 into main Apr 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants